package com.yan.utils;


import jodd.http.HttpRequest;
import jodd.http.HttpResponse;

public class JoddUtil {


    /**
     * http://www.yeetrack.com/?p=1232
     * body() – 原生的body内容，经常是以ISO-8859-1编码的
     * bodyText() – body文本，以http头”Content-Type”指明的方式编码
     * bodyBytes() – 原生的字节流，所以可以用来下载文件
     */

    public void test() {
//		String url = "http://192.168.70.213:8080/chatServer/chat/sendPChatMessage/android/football?lang=zh&timeZone=8&message=&chatType=football&toUserId=null&sourceName=android&msgCode=1&msgId=e10ea908-dae9-4824-9ebf-5262f04d577b&thirdId=3482618&deviceId=357095063448756&userId=hhly90320&phoneNum=13570185327&userLogo=http://tp.13322.com/img/2017-06-06/9212f265-8f28-40e3-9032-a2cb412e633c.jpg&userNick=诸葛看盘";
        String url = "http://localhost:10088/JFinal/indexJson";
        HttpRequest httpRequest = HttpRequest.get(url).header("Accept-Encoding", "gzip");
        HttpResponse response = httpRequest.send().accept("utf-8")
                .header("Content-Type", "application/json;charset=UTF-8").header("Content-Encoding", "gzip");

        System.out.println(response.body());
        System.out.println(GzipUtil.unGZip(response.bodyText()));

//			HttpClient client = (HttpClient) new HttpClientContext();
//			HttpPost post = new HttpPost(url);
//			
//			org.apache.http.HttpRequest request =new Htt
//			HttpResponse rep=	client.execute(post, paramHttpRequest)
//		 
//			Header[] headers = rep.getHeaders("Content-Encoding");
//			boolean isGzip = false;
//			for (Header h : headers) {
//				if (h.getValue().equals("gzip")) {
//					// 返回头中含有gzip
//					isGzip = true;
//				}
//			}
//			String responseString = null;
//			if (isGzip) {
//				// 需要进行gzip解压处理
//				responseString = EntityUtils.toString(new GzipDecompressingEntity(rep.getEntity()));
//			} else {
//				responseString = EntityUtils.toString(rep.getEntity());
//			}


    }

    public static void main(String args[]) {


    }
}
